#define  _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<bits/stdc++.h>
using namespace std;


stack<int> ans;

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		string s;
		cin >> s;

		int num = 0, way = 0;
		bool flag = 0;

		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] >= '0' && s[i] <= '9')
			{
				num++;
			}
			if (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/')
			{
				way++;
			}
		}

		if (num - way != 1)
		{
			cout << "Expression Error!" << endl;
			continue;
		}

		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] >= '0' && s[i] <= '9')
			{
				ans.push(s[i] - '0');
			}

			if (s[i] == '+')
			{
				int a = ans.top();
				ans.pop();
				int b = ans.top();
				ans.pop();
				ans.push(a + b);
			}

			else if (s[i] == '-')
			{
				int a = ans.top();
				ans.pop();
				int b = ans.top();
				ans.pop();
				ans.push(b - a);
			}

			else if (s[i] == '*')
			{
				int a = ans.top();
				ans.pop();
				int b = ans.top();
				ans.pop();
				ans.push(b * a);
			}

			else if (s[i] == '/')
			{
				int a = ans.top();
				ans.pop();
				int b = ans.top();
				ans.pop();
				if (a)
				{
					ans.push(b / a);
				}
				else
				{
					cout << "Division By Zero!" << endl;
					flag = 1;
					break;
				}
			}
		}

		if (flag)
		{
			continue;
		}

		cout << ans.top() << endl;
	}

	return 0;
}
